package com.zhongke.cotrun.model.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import org.springframework.format.annotation.DateTimeFormat;

import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.validation.constraints.NotNull;

@ApiModel(value = "资金日志明细表")
@Data
public class PayCapitallog {
	
	@ApiModelProperty(value = "id主键", example = "123")
	@TableId(type = IdType.AUTO)
	@NotNull(message = "id不能为空")
    private Long id;     
	
    @ApiModelProperty(value = "用户表主键", example = "123")
    @NotNull(message = "用户表主键不能为空")
    private Long userInfoId;
    
    @ApiModelProperty(value = "商品基础信息表主键", example = "123")
    private Long mallId;
    
    @ApiModelProperty(value = "订单号", example = "123")    
    @NotNull(message = "订单号不能为空")
    private String orderCode;
    
    @ApiModelProperty(value = "操作类型，数据字典，动态", example = "income")    
    private String type;
    
    @ApiModelProperty(value = "变动前余额", example = "1.000")    
    private double moneyBefore;
    
    @ApiModelProperty(value = "变动金额", example = "1.000")    
    private double moneyAdd;
    
    @ApiModelProperty(value = "变动后余额", example = "1.000")    
    private double moneyAfter;
    
    @ApiModelProperty(value = "备注", example = "123")   
    private String remarks;//备注
    @ApiModelProperty(value = "创建人", example = "123")  
    private Long createBy;
    @ApiModelProperty(value = "更新人", example = "123")  
    private Long updateBy;
    @ApiModelProperty(value = "创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createDate;    
    @ApiModelProperty(value = "更新时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateDate;    
    @ApiModelProperty(value = "删除标记（0：正常；1：回收站）", example = "0")    
    private String delFlag;
    
   public void setIncomeRemarks(PayBankroll bk) {
		StringBuffer str = new StringBuffer();
		DecimalFormat format = new DecimalFormat("0.00");
		format.setRoundingMode(RoundingMode.HALF_UP);
		
		str.append("单号【").append(bk.getOrderCode()).append("】")
			.append("在【").append(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(bk.getPayDate())).append("】")
			.append("进行了入账操作，入账金额【").append(format.format(bk.getAmount())).append("】 - 已入账");
		this.remarks = str.toString();
	}
	public void setPayOrderRemarks(PayBankroll bk) {
		StringBuffer str = new StringBuffer();
		DecimalFormat format = new DecimalFormat("0.00");
		format.setRoundingMode(RoundingMode.HALF_UP);
		
		str.append("单号【").append(bk.getOrderCode()).append("】")
			.append("在【").append(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(bk.getPayDate())).append("】")
			.append("进行了订单支付操作，订单金额【").append(format.format(bk.getAmount())).append("】 - 已支付");
		this.remarks = str.toString();
	}
}
